# arthor vuong.quoc
#! C:/Perl/bin/perl -w
use strict;
use warnings;
use diagnostics;
# arr hold all router
my @data;
sub searchFile
{	

	my @fileName;
	# print "Input search : ";
	# my $input = <STDIN>;
	my $path = "D:/param";#<STDIN>;
	chomp($path);
	opendir (DIR, $path) or die $!;
	while(my $file = readdir(DIR))
	{
		if($file !~ m/^\./)
		{
			push(@fileName,$file);
		}
	}                                      
	closedir DIR;
	foreach my $file (@fileName)
	{
		
		my $topology;
		open File, ("+<$path"."/"."$file") or die $!;
		my @list = <File>;
		my $size = @list;
		my $i;
		my $flag = 0;
		my $row ="";
		# print $file,"\n";
		for($i=0;$i<$size;$i++)
		{	
			
			# # remove space & comment
			# $list[$i] = &removeComment($list[$i]);
			# if($list[$i] =~ m/static {/)
			if($list[$i] =~ m/qpic/)
			{
				print $file,"\n";
			}
			# print $list[$i];
			# # Read file to obj
			# if($list[$i] =~ m/x-test-topology/)
			# {
				# while($list[$i] !~ m/\;/)
				# {
					# # $list[$i] = &removeComment($list[$i]);
					# $topology = $topology."$list[$i]";
					# $i++;
				# }
				# $topology = $topology."$list[$i]";
				
			# }
			
		}
	
	# print $data[20]->showAll();
	}
	print "Successfull!\n";
}
# Remove all Space in first and in the end.
sub regex_or {
  my $string = shift;
  if($string)
  {
    $string =~ s/(?:^\s+)||(?: +$)//g;
  }
  return $string;
}
# Remove all space and comment
sub removeComment
{
  my $string = shift;
  my @results = split("#",$string);
  $string =regex_or($results[0]);
  return $string;
}
#function reardpara()
&searchFile();